<template>
  <el-dialog
    class="archives-upload-file-modal"
    title="上传文件"
    :close-on-click-modal="false"
    :destroy-on-close="true"
    :visible="visible"
    :width="$setRem(500)"
    :before-close="handleCancel">
    <div class="content">
      <div class="row">
        <span class="label">一级文件夹</span>
        <div class="input-content">
          <el-select v-model="value1" placeholder="请选择">
<!--            <el-option-->
<!--              v-for="(item, index) in projectList"-->
<!--              :value="item.project_id"-->
<!--              :label="item.project_name"-->
<!--              :key="index"-->
<!--              :title="item.project_name"-->
<!--            >-->
<!--            </el-option>-->
          </el-select>
          <i class="el-icon-plus" @click="addDir('1')"></i>
        </div>
      </div>
      <div class="row">
        <span class="label">二级文件夹</span>
        <div class="input-content">
          <el-select v-model="value2" placeholder="请选择"></el-select>
          <i class="el-icon-plus" @click="addDir('2')"></i>
        </div>
      </div>
      <div class="row">
        <span class="label">一级文件夹</span>
        <div class="input-content">
          <el-upload
            class="upload-container"
            action="custom"
            :on-remove="handleRemove"
            :on-change="handleChange"
            :file-list="fileList"
            :limit="1">
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </div>
      </div>
    </div>
    <el-dialog
      class="add-dir-modal"
      append-to-body
      title="新建文件夹"
      :close-on-click-modal="false"
      :destroy-on-close="true"
      :visible="addVisible"
      :width="$setRem(500)"
      :before-close="handleClose">
      <div class="content">
        <div class="row">
          <span class="label">一级文件夹</span>
          <div class="input-content">
            <el-input placeholder="请输入" v-model="firstLevel"></el-input>
          </div>
        </div>
        <div class="row">
          <span class="label">二级文件夹</span>
          <div class="input-content">
            <el-input placeholder="请输入" v-model="secondary"></el-input>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleClose">取 消</el-button>
        <el-button
          class="success"
          type="primary"
          :loading="btnLoading"
          @click="handleAdd">
          确 定
        </el-button>
      </div>
    </el-dialog>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleCancel">取 消</el-button>
      <el-button
        class="success"
        type="primary"
        :loading="btnLoading"
        @click="handleSubmit">
        确 定
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      btnLoading: false,
      addVisible: false,
      value1: '',
      value2: '',
      firstLevel: '',
      secondary: '',
      type: '1',
      fileList: []
    };
  },
  watch: {
    visible(val) {
      if (!val) {
        this.btnLoading = false;
      }
    },
    addVisible(val) {
      if (!val) {
        this.firstLevel = '';
        this.secondary = '';
      }
    }
  },
  methods: {
    addDir(type) {
      this.type = type;
      this.addVisible = true;
    },
    handleRemove() {

    },
    handleChange() {

    },
    handleSubmit() {

    },
    handleClose() {
      this.addVisible = false;
    },
    handleCancel() {
      this.$emit('cancel', false);
    }
  }
};
</script>

<style scoped lang="scss">
  @import '../../../assets/styles/dialog';

  .archives-upload-file-modal {
    .content {
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .row {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 20px;
        .label {
          width: 120px;
          color: $mainColor;
        }
        .input-content {
          width: 300px;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          .el-icon-plus {
            font-size: 20px;
            margin-left: 20px;
            cursor: pointer;
            &:hover {
              color: $mainColor;
            }
          }
        }
      }
    }
  }
</style>
